﻿using iTelluro.Explorer.Infrastructure.CrossCutting.Logging;
using iTelluro.Explorer.Infrastructure.CrossCutting.NetFramework.Logging;
using Quartz;
using SXMeteorological.Data.Utility;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace SXMeteorological.DataSyn.Humidity
{
    public class HumidityJob:IJob
    {
        private readonly ILogger _logger;
        public HumidityJob()
        {
            _logger = LoggerFrameFactory.CreateLog();
           // _logger.LogInfo("执行湿度任务构造函数");
        }

        public void Execute(IJobExecutionContext context)
        {
            RelativeHumidity();
            LowerHumidity();
        }
        /// <summary>
        /// 相对湿度
        /// </summary>
        private void RelativeHumidity()
        {
            try
            {
                string interfaceName = "getSurfEleInRegionByTime";
                string returnValue = "Lat,Lon,RHU";
                string featureName = "逐小时相对湿度";
                string time = DateTime.UtcNow.ToString("yyyyMMddHH") + "0000";
                string dataCode = "SURF_CHN_MUL_HOR";
                string colorpath = AppDomain.CurrentDomain.BaseDirectory + @"color\humidity.txt";
                CreateMap.CreateFeatureMap(interfaceName, returnValue, dataCode, featureName, "逐小时相对湿度图", time, colorpath, "h");
            }
            catch (Exception ex)
            {
                _logger.LogError(string.Format("陕西省相对湿度数据生成失败#{0}：{1}", DateTime.Now, ex.Message));
            }
        }
       /// <summary>
       /// 最小相对湿度
       /// </summary>
        private void LowerHumidity()
        {
            try
            {
                string interfaceName = "getSurfEleInRegionByTime";
                string returnValue = "Lat,Lon,RHU_Min";
                string featureName = "最小相对湿度";
                string time = DateTime.UtcNow.ToString("yyyyMMddHH") + "0000";
                string dataCode = "SURF_CHN_MUL_HOR";
                string colorpath = AppDomain.CurrentDomain.BaseDirectory + @"color\humidity.txt";
                CreateMap.CreateFeatureMap(interfaceName, returnValue, dataCode, featureName, "最小相对湿图", time, colorpath, "h");
            }
            catch (Exception ex)
            {
                _logger.LogError(string.Format("陕西省最小相对湿度数据生成失败#{0}：{1}", DateTime.Now, ex.Message));
            }
        }
    }
}
